//============================================================================
// Name        : ms004.cpp
// Author      : Tadas
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include "lib.h"
#include <cmath>
using namespace std;

double function(double x){
	return fabs(x)/4 + cos(3*x) + sin(3*x);
}

double functiond(double x){
	return 1/4 - 3*sin(3*x) + 3*cos(3*x);
}

void Ans(double i, char * type, int ite){
	cout << "Saknis rasta: " << i << " Type: " << type << " iteracijos: " << ite << endl;
}

int main() {
	double x1 = -10.0, x2 = 10.0;
	int n = 1000, nb = 10000, nc = nb;
	double *xb1, *xb2;
	int ite = 0;
	
	double rez;
	
	xb1 = new double[nb];
	xb2 = new double[nb];
	
	brac_m(function, x1, x2, n, xb1, xb2, nb);
	
	assert(nb != nc);
	
	for(int i = 0; i < nb; i++){
		ite = 0;
		rez = bisec(function, xb1[i], xb2[i], ite);
		Ans(rez, "bisec", ite);
		ite = 0;
		rez = secant(function, xb1[i], xb2[i], ite);
		Ans(rez, "secant", ite);
		ite = 0;
		rez = newtRaps(function, functiond, xb1[i], xb2[i], ite);
		Ans(rez, "newtRaps", ite);
	}
	cout << "Baigta" << endl;
	return 0;
}
